package com.ludomancy.spaceopera;

import java.awt.Graphics;
import java.awt.Point;
import com.ludomancy.gamelib.ImageStrip;
import com.ludomancy.gamelib.ResourceManager;

public class InventoryItem extends BasicEntity
{
	private ImageStrip sprites;
	
	// items
	public static final int TYPE_PULLER = 0;
	public static final int TYPE_SCANNER = 1;
	public static final int TYPE_TRANSILIENT = 2;
	public static final int TYPE_KWIZATZ = 3;
	public static final int TYPE_BLASTER = 4;
	public static final int TYPE_CLASSES = 5;
	private int type;
	
	protected int cost;
	protected String desc;
	protected boolean consumable = false;
	protected String buyLabel;

	public InventoryItem(int type)
	{
		super(new Point());
		this.type = type;
		sprites = new ImageStrip(ResourceManager.getImage("buttons.png"), 20, 24);
		buyLabel = "Build";
		switch(type)
		{
			case TYPE_KWIZATZ:
				desc = "Kwizatz Haderach: This blue-eyed prescient allows your lander to avoid hazard damage.";
				cost = 50;
				buyLabel = "Recruit";
				break;
			case TYPE_TRANSILIENT:
				desc = "Transilient Propulsor: You teleport instead of moving around. Subtle, but useful.";
				cost = 200;
				consumable = true;
				buyLabel = "Install";
				break;
		}
		width = (int) proj.screenToWorldX(sprites.frameWidth);
		height = (int) proj.screenToWorldY(sprites.frameHeight);
	}
	
	public String getBuyLabel()
	{
		return buyLabel;
	}
	
	public void paintPlayerUnderlay(Graphics g, int x, int y)
	{
		
	}
	
	public boolean isConsumable()
	{
		return consumable;
	}
		
	public void paint(Graphics g, int x, int y)
	{
		sprites.paint(g,type, x, y);
	}
	
	public int getType()
	{
		return type;
	}
	
	public String getDescription()
	{
		return desc;
	}
	
	public int getCost()
	{
		return cost;
	}
	
	public void update(Player player, boolean activated)
	{
		switch(type)
		{
			case TYPE_KWIZATZ:
				player.landerShielded = activated;
				break;
		}
	}

	public boolean canBeUsed()
	{
		switch(type)
		{
			case TYPE_KWIZATZ:
				return Game.game.currentWorld instanceof LandWorld;
		}
		return false;
	}

	public void grant()
	{
		if(isConsumable())
		{
			switch(type)
			{
				case TYPE_TRANSILIENT:
					Game.game.player.hasTransilient = true;
					break;
			}
		}
		else
		{
			Game.game.player.inventory = this;
		}
	}
	
	public String getInteractionVerbFor(BasicEntity e)
	{
		return e.getInteractionVerb();
	}

	public boolean interact(BasicEntity e)
	{
		return false;
	}
}
